package com.sx.pipeline.ui.agreement

import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.sx.mvvmlibs.utils.Logs
import com.sx.pipeline.R
import com.sx.pipeline.app.base.CYBaseAppBarActivity
import com.sx.pipeline.app.config.IntentKey
import com.sx.pipeline.app.model.CYBaseViewModel
import com.sx.pipeline.app.web.WebViewFragment
import com.sx.pipeline.arouth.RoutePath
import com.sx.pipeline.databinding.ActAgreementBinding
import com.sx.pipeline.repos.http.res.AgreementVO

/**
 * @Author: YY
 * @Date: 2022/4/26
 * @Description: TODO
 */
@Route(path = RoutePath.Register.USER_AGREEMENT)
class AgreementActivity: CYBaseAppBarActivity<ActAgreementBinding, CYBaseViewModel>(R.layout.act_agreement) {

    @Autowired(name = IntentKey.DATA)
    @JvmField
    var userAgreement : AgreementVO? = null

    override fun initData() {
        super.initData()
        if (userAgreement != null) {
            loadRootFragment(userAgreement!!)
        }
    }

    private fun loadRootFragment(data: AgreementVO) {
        Logs.d("loadRootFragment ${data.content}")
        getTitleBar().title = userAgreement!!.title
        supportFragmentManager.beginTransaction().add(R.id.fl_container,
            WebViewFragment.newInstance("", data.content)
        ).commit()
    }
}